#include<bits/stdc++.h>
using namespace std;

int main() {
	freopen("arena.in", "r", stdin);
	freopen("arena.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	int a[n], c[m];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> c[i];
	}
	int k = -1;
	while((1 << (k + 1)) >= n) {
		k++;
	}
	
	vector <int> v[k + 1];

	for(int i = 1; i <= k; i++) {
		v[i].resize(1 << (k - i));
		string s;
		cin >> s;
		for(int j = 0; j < (1 << (k - i)); j++) {
			cin >> v[i][j];
		}
	}
	int t;
	cin >> t;
	int x11[t], x22[t], x33[t], x44[t];
	for(int i = 0; i < t; i++) {
		cin >> x11[i] >> x22[i] >> x33[i] >> x44[i];
	}
	
	return 0;
}
